<?php

class Departments extends Model {

	function Departments() {
		parent::Model();
	}

	function create( $name, $description ) {
		$sql = 'insert into `departments`(`name`, `description`)'
			.'values( ?, ?)';
		$this->db->query($sql, array($name, $description));
	}

	function fetch( $department_id ) {
		$sql = 'select * from `departments` where `department_id`=?';
		$r = $this->db->query($sql, array($department_id));
		return $r->row();
	}

	function fetch_all() {
		$sql = 'select * from `departments`';
		$r = $this->db->query($sql);
		return $r->result();
	}

	function remove( $department_id ) {
		$sql = 'delete from `departments` where `department_id`=?';
		$this->db->query($sql, array($department_id));
	}
}

?>
